/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2012/07/12
* File: MaterialData.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#ifndef MaterialData_h__
#define MaterialData_h__

#include "../Core/Core.h"
#include "../Core/Declare.h"

class TextureLayer
{
public:
	TextureLayer()
		: _texture(NULL)
		, _texture_wrap_u(ETC_REPEAT)
		, _texture_wrap_v(ETC_REPEAT)
		, _is_linear_filter(true)
	{

	}

	Texture*		_texture;
	u8				_texture_wrap_u : 4;
	u8				_texture_wrap_v : 4;
	bool			_is_linear_filter;
};

class MaterialData
{
public:
	typedef				glm::vec4 ColorType;

	/* default value */
	MaterialData()
		: _ambient_color(0.0f, 0.0f, 0.0f, 1.0f)
		, _diffuse_color(0.0f, 0.0f, 0.0f, 1.0f)
		, _specular_color(0.0f, 0.0f, 0.0f, 1.0f)
		, _emissive_color(0.0f, 0.0f, 0.0f, 0.0f)
		, _shiness(0.0f)
		, _wireframe(false)
		, _lighting(false)
		, _gouraud_shading(false)
		, _back_face_culling(true)
		, _front_face_culling(false)
		, _zwrite_enable(true)
		, _zbuffer(ECFN_LESSEQUAL)
	{

	}

	Texture* getTexture(u32 i) const
	{
		return i > MaxTextureSupport - 1 ? 0 : _texture_layer_list[i]._texture;
	}

	ColorType			_ambient_color;
	ColorType			_diffuse_color;
	ColorType			_specular_color;
	ColorType			_emissive_color;
	f32					_shiness;
	bool				_wireframe : 1;
	bool				_lighting : 1;
	bool				_gouraud_shading : 1;
	bool				_back_face_culling : 1;
	bool				_front_face_culling : 1;
	bool				_zwrite_enable : 1;
	u8					_zbuffer;


	TextureLayer		_texture_layer_list[MaxTextureSupport];
};

#endif    /* MaterialData_h__ */